<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
<script type="text/javascript" src="lib/html5shiv.js"></script>
<script type="text/javascript" src="lib/respond.min.js"></script>
<![endif]-->

<link href="/Public/Admin/static/h-ui/css/H-ui.min.css" rel="stylesheet" type="text/css" />
<link href="/Public/Admin/static/h-ui.admin/css/H-ui.login.css" rel="stylesheet" type="text/css" />
<link href="/Public/Admin/static/h-ui.admin/css/style.css" rel="stylesheet" type="text/css" />
<link href="/Public/Admin/lib/Hui-iconfont/1.0.8/iconfont.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="/Public/Admin/static/h-ui.admin/css/H-ui.admin.css" />
<link rel="stylesheet" type="text/css" href="/Public/Admin/static/h-ui.admin/skin/default/skin.css" id="skin" />

<script type="text/javascript" src="/Public/Admin/lib/jquery/1.9.1/jquery.min.js"></script> 

<!--[if IE 6]>
<script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<title></title>
<meta name="keywords" content="H-ui.admin v3.1,H-ui网站后台模版,后台模版下载,后台管理系统模版,HTML后台模版下载">
<meta name="description" content="H-ui.admin v3.1，是一款由国人开发的轻量级扁平化网站后台模板，完全免费开源的网站后台管理系统模版，适合中小型CMS后台系统。">
</head>
<body>
	
<div class="page-container">
	<form action="<?php echo U('NewBlogCat/add');?>" method="post" class="form form-horizontal" id="form-user-add">
		
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>上级分类：</label>
			<div class="formControls col-xs-6 col-sm-6">
				<span class="select-box">
				<select name="pid" class="select">
					<option value="0">第一级分类</option>
					<?php if(is_array($list)): foreach($list as $key=>$v): ?><option value="<?php echo ($v['cat_id']); ?>" <?php if($v['cat_id']==$res['pid']): ?>selected<?php endif; ?> ><?php echo str_repeat('==',$v['C_count']); echo ($v['cat_name']); ?></option><?php endforeach; endif; ?>
				</select>
				</span>
			</div>
		</div>
		
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">
				<span class="c-red">*</span>
				分类名称：</label>
			<div class="formControls col-xs-6 col-sm-6">
				<input type="text" class="input-text" name="cat_name" value="<?php echo ($res['cat_name']); ?>" placeholder="" id="user-name" name="product-category-name">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">排序：</label>
			<div class="formControls col-xs-6 col-sm-1">
				<input type="text" class="input-text" name="sort" value="<?php echo ($res['sort']); if(empty($res)): ?>0<?php endif; ?>"  placeholder="" id="user-name" name="product-category-name">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>是否显示：</label>
			<div class="formControls col-xs-6 col-sm-6 skin-minimal">
				<div class="radio-box">
					<input name="is_show" type="radio" value="1" id="sex-1" <?php if($res["is_show"]==1): ?>checked<?php endif; ?> <?php if(empty($res)): ?>checked<?php endif; ?> >
					<label for="sex-1">显示</label>
				</div>
				<div class="radio-box">
					<input type="radio" <?php if($res["is_show"]==="0"): ?>checked<?php endif; ?> id="sex-2" value="0" name="is_show">
					<label for="sex-2">隐藏</label>
				</div>
			</div>
		</div>
		
		<div class="row cl">
			<div class="col-9 col-offset-1">
				<input type="hidden" name="id" value="<?php echo ($res['cat_id']); ?>" />
				
				
				<?php if(!empty($res)): ?><input class="btn btn-primary radius" type="button" onclick="updateAction(this)" value="&nbsp;&nbsp;修改分类&nbsp;&nbsp;">
				<input class="btn btn-danger radius" onclick="deleteCat(<?php echo ($res['cat_id']); ?>)" type="button" value="&nbsp;&nbsp;删除分类&nbsp;&nbsp;">
				<?php else: ?>
				<input class="btn btn-primary radius" type="button" onclick="addAction(this)"  value="&nbsp;&nbsp;添加分类&nbsp;&nbsp;"><?php endif; ?>
			</div>
		</div>
	</form>
</div>

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript">
function addAction(obj){
	
	$(obj).append($('<input type="hidden" name="is_add" value="1">'));
	$("form:first").submit();
}

function updateAction(obj){
	$(obj).append($('<input type="hidden" name="is_add" value="0"/>'));
	$('form:first').submit();
}
function deleteCat(id){
	
	$.post("<?php echo U('NewBlogCat/delete');?>",{id:id},function (data){
		
		if(data == 1){ // 删除成功
			alert('删除成功');
			parent.location.reload();
		}else { // 删除失败
			alert('删除失败，请稍后重试');
		}
		
	});
	
}

$(function(){
	
	
	
	$('.skin-minimal input').iCheck({
		checkboxClass: 'icheckbox-blue',
		radioClass: 'iradio-blue',
		increaseArea: '20%'
	});
	
	$("#form-user-add").validate({
		rules:{
			username:{
				required:true,
				minlength:2,
				maxlength:16
			},
			sex:{
				required:true,
			},
			mobile:{
				required:true,
				isMobile:true,
			},
			email:{
				required:true,
				email:true,
			},
			uploadfile:{
				required:true,
			},
			
		},
		onkeyup:false,
		focusCleanup:true,
		success:"valid",
		
	});

});
</script>

	
<script type="text/javascript" src="/Public/Admin/static/h-ui/js/H-ui.min.js"></script>
<script type="text/javascript" src="/Public/Admin/lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="/Public/Admin/static/h-ui.admin/js/H-ui.admin.js"></script> 
<script type="text/javascript" src="/Public/Admin/lib/My97DatePicker/4.8/WdatePicker.js"></script> 
<script type="text/javascript" src="/Public/Admin/lib/datatables/1.10.0/jquery.dataTables.min.js"></script> 
<script type="text/javascript" src="/Public/Admin/lib/laypage/1.2/laypage.js"></script>
<script type="text/javascript" src="/Public/Admin/lib/jquery.validation/1.14.0/jquery.validate.js"></script> 
<script type="text/javascript" src="/Public/Admin/lib/jquery.validation/1.14.0/validate-methods.js"></script> 
<script type="text/javascript" src="/Public/Admin/lib/jquery.validation/1.14.0/messages_zh.js"></script>

<script type="text/javascript" src="/Public/Admin/lib/webuploader/0.1.5/webuploader.min.js"></script> 
<script type="text/javascript" src="/Public/Admin/lib/ueditor/1.4.3/ueditor.config.js"></script> 
<script type="text/javascript" src="/Public/Admin/lib/ueditor/1.4.3/ueditor.all.min.js"> </script> 
<script type="text/javascript" src="/Public/Admin/lib/ueditor/1.4.3/lang/zh-cn/zh-cn.js"></script>
<script type="text/javascript" src="/Public/Admin/lib/zTree/v3/js/jquery.ztree.all-3.5.min.js"></script>
</body>
</html>